package pk.campustour;


import java.util.ArrayList;
import java.util.Arrays;
import android.app.ListActivity;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
 
public class PlacesActivity extends ListActivity {
	private ListView mainListView ;  
	  private ArrayAdapter<String> listAdapter ;  
private  String[] categories;
private  String[] department;
private ArrayList<String> placesList;
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
                
        
        
                
        setContentView(R.layout.activity_places);

    }
	@Override
    public void onResume()
    {
    	super.onResume();
    	//Toast.makeText(VideosActivity.this,"I am back.!!! " , Toast.LENGTH_SHORT).show();
    	department = new String[]{"Department of Bio-Technology", "Department of Education","Department of Physics", "Department of Chemistry","Department of Mass Communication"};
		  String value = getIntent().getStringExtra("Item");
		  if(value!=null)
		  {
			 // Toast.makeText(VideosActivity.this,"Value:: " + value, Toast.LENGTH_SHORT).show();
			  if(value=="Department")
			  {
				  placesList = new ArrayList<String>();
				  placesList.addAll( Arrays.asList(department) );  

				  // Create ArrayAdapter using the category list.  
				    

				  listAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, placesList);
				  
				  listAdapter.add( "Extra" );  
				  listAdapter.add( "Extra" );
				  Toast.makeText(PlacesActivity.this,"Value:: " + value, Toast.LENGTH_SHORT).show();
			  }
		  }
		  else
		  {
		        mainListView = (ListView)findViewById( android.R.id.list );  

				  // Create and populate a List of planet names.  
				  categories = new String[] { "Department of Bio-Technology", "Department of Education", "Main Cafeteria", "Main Library",  
				                                  "IR Bus Stop", "Quarter Stop", "Department of Physics", "Department of Chemistry","Department of Mass Communication"};
				  //Toast.makeText(VideosActivity.this,"Value is null " , Toast.LENGTH_SHORT).show();
				  placesList = new ArrayList<String>();
				  placesList.addAll( Arrays.asList(categories) );  
				  // Create ArrayAdapter using the category list.  
				  listAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, placesList);
				  listAdapter.add( "Extra" );  
				  listAdapter.add( "Extra" );
				  //Set the ArrayAdapter as the ListView's adapter.
		  }
		  mainListView.setAdapter( listAdapter );
    }
    @Override
    public void onListItemClick(ListView l, View v, int position, long id)
    {
    	String item = (String) listAdapter.getItem(position);
    	Toast.makeText(PlacesActivity.this,"Item Selected " + item, Toast.LENGTH_SHORT).show();
    	
    	Intent description = new Intent(PlacesActivity.this,DescriptionActivity.class);
        startActivity(description);
    }
}